<?php

namespace Modules\Manager\Entities;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Modules\Manager\Entities\Manager;

class Department extends Model
{
    use HasFactory;

    protected $guarded = [];

    protected function serializeDate(\DateTimeInterface $date)
    {
        return $date->format('Y-m-d H:i:s');
    }
    public function setUseOtherShopCustomerAttribute($value)
    {
        $this->attributes['use_other_shop_customer'] = json_encode($value);
    }
    public function getUseOtherShopCustomerAttribute($value)
    {
        return json_decode($value,true);
    }
    public function setChangePriceNotifyAttribute($value)
    {
        $this->attributes['change_price_notify'] = json_encode($value);
    }
    public function getChangePriceNotifyAttribute($value)
    {
        return json_decode($value,true);
    }
    public function user(){
        return $this->belongsTo(Manager::class,'id','department_id');
    }
}
